package com.rj.framework.component;

import java.lang.reflect.Type;

// 自定义异常提供详细信息
public class ComponentTypeMismatchException extends RuntimeException {
    public ComponentTypeMismatchException(String componentName,
                                          Type actualInputType, Type expectedInputType,
                                          Type actualOutputType, Type expectedOutputType,
                                          Type actualContextType, Type expectedContextType) {

        super(String.format(
                "Component '%s' type mismatch!\n" +
                        "Expected: BusinessComponent<%s, %s, %s>\n" +
                        "Actual:   BusinessComponent<%s, %s, %s>",
                componentName,
                expectedInputType.getTypeName(),
                expectedOutputType.getTypeName(),
                expectedContextType.getTypeName(),
                actualInputType.getTypeName(),
                actualOutputType.getTypeName(),
                actualContextType.getTypeName()
        ));
    }
}